{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": "auth success \n"
    }
   ],
   "source": [
    "import jqdatasdk\n",
    "jqdatasdk.auth(\"13695683829\",\"ssk741212\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": "{'total': 1000000, 'spare': 993274}"
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "jqdatasdk.get_query_count()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": "auth success \n(0.0, 3648.4636)\n"
    }
   ],
   "source": [
    "\n",
    "#引入自定义库\n",
    "import sys\n",
    "sys.path.append('../TL')\n",
    "from tl import *\n",
    "print(get_divid('600000.XSHG',\"2020-01-14\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": "stk_sz_002415.csv\n<Response [200]>\nmcr_u10y.csv\n<Response [200]>\ncmm_value.csv\n<Response [200]>\nidx_sh_000977.csv\n<Response [200]>\nidx_sz_399976.csv\n<Response [200]>\nmcr_u5y.csv\n<Response [200]>\nstk_bank_change.csv\n<Response [200]>\ncmm_gsr.csv\n<Response [200]>\nidu_sw1_801130.csv\n<Response [200]>\nstk_sz_002807.csv\n<Response [200]>\nstk_pool_gw300.csv\n<Response [200]>\nstk_pool_gwcyb.csv\n<Response [200]>\nstk_sh_600036.csv\n<Response [200]>\nidx_sh_000931.csv\n<Response [200]>\nidu_sw1_change.csv\n<Response [200]>\nidx_relevance.csv\n<Response [200]>\nidu_sw1_801110.csv\n<Response [200]>\nidx-img-qscpe.png\n<Response [400]>\nidx-img-qscpe.png\nidu_sw1_801180.csv\n<Response [200]>\nmcr_bdi.csv\n<Response [200]>\nmsg_xqwz_4776750571.csv\n<Response [200]>\nstk_sh_600887.csv\n<Response [200]>\nmsg_blog_60278066.csv\n<Response [200]>\nstk_sh_600566.csv\n<Response [200]>\nidu_sw1_801080.csv\n<Response [200]>\nstk_sh_601166.csv\n<Response [200]>\nidx-img-kj.png\n<Response [400]>\nidx-img-kj.png\nstk_sh_601818.csv\n<Response [200]>\nmsg_xqwz_5941996397.csv\n<Response [200]>\nstk_pool_gw1000.csv\n<Response [200]>\nidx_sh_000989.csv\n<Response [200]>\nidx_data.db\n<Response [400]>\nidx_data.db\nmcr_udi.csv\n<Response [200]>\nidu_sw1_801150.csv\n<Response [200]>\nidu_sw1_801760.csv\n<Response [200]>\nidx_sh_000015.csv\n<Response [200]>\nidx_sh_000990.csv\n<Response [200]>\nidx_hw_spx.csv\n<Response [200]>\nidx_sz_399106.csv\n<Response [200]>\nidx_hw_n225.csv\n<Response [200]>\nidx_sz_399550.csv\n<Response [200]>\nstk_sh_600015.csv\n<Response [200]>\nmsg_weixin_长赢指数投资.csv\n<Response [200]>\nidu_sw1_801710.csv\n<Response [200]>\nmcr_vix.csv\n<Response [200]>\nidu_sw1_801880.csv\n<Response [200]>\nstk_roe20_value.csv\n<Response [200]>\nmcr_scn.csv\n<Response [200]>\nidx_sz_399812.csv\n<Response [200]>\nmsg_weibo_1254381361.csv\n<Response [200]>\nplt_sha.csv\n<Response [200]>\nidx_relevance.png\n<Response [400]>\nidx_relevance.png\nstk_sh_600660.csv\n<Response [200]>\nmcr_c5y.csv\n<Response [200]>\nidx_sh_000991.csv\n<Response [200]>\nmsg_weixin_梧桐拾贝社.csv\n<Response [200]>\nidx_hw_hsi.csv\n<Response [200]>\nidu_sw1_801210.csv\n<Response [200]>\nstk_sh_601877.csv\n<Response [200]>\nidx_change.csv\n<Response [200]>\nidx_hw_ftse.csv\n<Response [200]>\nstk_sh_600016.csv\n<Response [200]>\nidx_sz_399989.csv\n<Response [200]>\nidx_pool.csv\n<Response [200]>\nstk_sh_601229.csv\n<Response [200]>\nstk_sz_002294.csv\n<Response [200]>\nstk_pool_roe20.csv\n<Response [200]>\nstk_sh_600926.csv\n<Response [200]>\nidx_sh_000922.csv\n<Response [200]>\nidx_sh_000068.csv\n<Response [200]>\nidx_sz_399975.csv\n<Response [200]>\nstk_pool_gw500.csv\n<Response [200]>\nstk_sh_600919.csv\n<Response [200]>\nidx_sz_399811.csv\n<Response [200]>\nidu_sw1_801770.csv\n<Response [200]>\nidx_sz_399986.csv\n<Response [200]>\nidx_hw_fchi.csv\n<Response [200]>\nstk_sz_002236.csv\n<Response [200]>\nstk_sz_002714.csv\n<Response [200]>\nidx-img-pbs.png\n<Response [400]>\nidx-img-pbs.png\nstk_sh_601939.csv\n<Response [200]>\nmcr_pmi.csv\n<Response [200]>\nmcr_uch.csv\n<Response [200]>\nstk_sz_000661.csv\n<Response [200]>\nidu_sw1_801890.csv\n<Response [200]>\nidu_sw1_801120.csv\n<Response [200]>\nstk_bank_value.csv\n<Response [200]>\nidx_sh_000010.csv\n<Response [200]>\nidu_sw1_801050.csv\n<Response [200]>\nmcr_cpi.csv\n<Response [200]>\nidx_sh_000827.csv\n<Response [200]>\nidx_sh_000906.csv\n<Response [200]>\nmsg_weixin_码农滚雪球.csv\n<Response [200]>\nstk_sh_600816.csv\n<Response [200]>\nidu_sw1_801200.csv\n<Response [200]>\nidx_sh_000841.csv\n<Response [200]>\nidx-img-qscpb.png\n<Response [400]>\nidx-img-qscpb.png\nidu_sw1_801740.csv\n<Response [200]>\nstk_pool_bank.csv\n<Response [200]>\nstk_roe20_change.csv\n<Response [200]>\nidx_sz_399001.csv\n<Response [200]>\nstk_sz_000688.csv\n<Response [200]>\ncmm_oil.csv\n<Response [200]>\nstk_sh_601988.csv\n<Response [200]>\nidu_sw1_801030.csv\n<Response [200]>\nidx_hw_hscei.csv\n<Response [200]>\nidx_sh_000016.csv\n<Response [200]>\nstk_sz_000333.csv\n<Response [200]>\nstk_sz_000001.csv\n<Response [200]>\nstk_sz_000538.csv\n<Response [200]>\nmsg_weibo_1669616825.csv\n<Response [200]>\nplt_value.csv\n<Response [200]>\nfnd_pool_index.csv\n<Response [200]>\ncmm_xau.csv\n<Response [200]>\nidx_sz_399101.csv\n<Response [200]>\nidx_sz_399324.csv\n<Response [200]>\nidx_hw_sx5e.csv\n<Response [200]>\nidu_sw1_801750.csv\n<Response [200]>\nidu_sw1_801780.csv\n<Response [200]>\nmcr_ms.csv\n<Response [200]>\nidx_sh_000902.csv\n<Response [200]>\nstk_sz_002142.csv\n<Response [200]>\nstk_sh_600908.csv\n<Response [200]>\nstk_sh_601398.csv\n<Response [200]>\nidx_sh_000993.csv\n<Response [200]>\nstk_sz_002081.csv\n<Response [200]>\nidu_sw1_value.csv\n<Response [200]>\ncmm_gor.csv\n<Response [200]>\nstk_sz_000651.csv\n<Response [200]>\nmcr_pool.csv\n<Response [200]>\nstk_sh_600000.csv\n<Response [200]>\nidx_sh_000300.csv\n<Response [200]>\nidu_sw1_801140.csv\n<Response [200]>\nstk_sh_601997.csv\n<Response [200]>\nidx_sz_399967.csv\n<Response [200]>\nstk_sh_601288.csv\n<Response [200]>\nidx_hw_ndaq.csv\n<Response [200]>\nidx-img-zj.png\n<Response [400]>\nidx-img-zj.png\nstk_sh_601998.csv\n<Response [200]>\nmsg_weixin_股市药丸.csv\n<Response [200]>\nstk_sh_603288.csv\n<Response [200]>\nstk_sh_600690.csv\n<Response [200]>\nidx_sz_399005.csv\n<Response [200]>\nplt_cyb.csv\n<Response [200]>\nmcr_shibor.csv\n<Response [200]>\ncmm_pool.csv\n<Response [200]>\nidu_sw1_801020.csv\n<Response [200]>\nidx_sh_000009.csv\n<Response [200]>\nstk_sh_601169.csv\n<Response [200]>\nstk_sh_603323.csv\n<Response [200]>\nstk_sh_600201.csv\n<Response [200]>\nidx_sh_000001.csv\n<Response [200]>\nmcr_c10y.csv\n<Response [200]>\nplt_sza.csv\n<Response [200]>\nidx_sh_000998.csv\n<Response [200]>\n.ipynb_checkpoints\n<Response [400]>\n.ipynb_checkpoints\nidu_sw1_801170.csv\n<Response [200]>\nstk_pool_edticket.csv\n<Response [200]>\nidx_sh_000807.csv\n<Response [200]>\nstk_sh_603898.csv\n<Response [200]>\nidx_sh_000992.csv\n<Response [200]>\nstk_sz_000423.csv\n<Response [200]>\nplt_zxb.csv\n<Response [200]>\nidx_sz_399997.csv\n<Response [200]>\nidx_sz_399624.csv\n<Response [200]>\ncmm_xag.csv\n<Response [200]>\nidx_sz_399006.csv\n<Response [200]>\nidx_sh_000905.csv\n<Response [200]>\nstk_sh_601515.csv\n<Response [200]>\nmcr_ppi.csv\n<Response [200]>\nstk_sz_000963.csv\n<Response [200]>\nplt_hsa.csv\n<Response [200]>\nidx_sh_000932.csv\n<Response [200]>\nmsg_weixin_阿甘数量化2.csv\n<Response [200]>\nidx_sz_399808.csv\n<Response [200]>\nidx_sz_399673.csv\n<Response [200]>\nidx_sh_000925.csv\n<Response [200]>\nstk_sh_601128.csv\n<Response [200]>\nstk_sz_002271.csv\n<Response [200]>\nidu_sw1_801790.csv\n<Response [200]>\nmsg_weibo_5687069307.csv\n<Response [200]>\nidx_sh_000904.csv\n<Response [200]>\nplt_szb.csv\n<Response [200]>\nplt_pool.csv\n<Response [200]>\nmcr_nfc.csv\n<Response [200]>\nmsg_xqft_4776750571.csv\n<Response [200]>\nstk_sz_002508.csv\n<Response [200]>\nidu_sw1_801010.csv\n<Response [200]>\nstk_sz_002032.csv\n<Response [200]>\nidx_sh_000903.csv\n<Response [200]>\nidu_pool_sw1.csv\n<Response [200]>\nstk_sh_600276.csv\n<Response [200]>\nidu_sw1_801730.csv\n<Response [200]>\nidx_sh_000852.csv\n<Response [200]>\nidx_sh_000986.csv\n<Response [200]>\nstk_sh_600340.csv\n<Response [200]>\ncmm_change.csv\n<Response [200]>\nidx_sh_000988.csv\n<Response [200]>\nidx_sh_000978.csv\n<Response [200]>\nidx_sz_399396.csv\n<Response [200]>\nstk_sh_600519.csv\n<Response [200]>\nstk_sz_000049.csv\n<Response [200]>\nidx_hw_djia.csv\n<Response [200]>\nidx_sz_399971.csv\n<Response [200]>\nidx_sz_399102.csv\n<Response [200]>\nidu_sw1_801230.csv\n<Response [200]>\n网格-交易A.xlsm\n<Response [400]>\n网格-交易A.xlsm\nmcr_gdp.csv\n<Response [200]>\nidx_sh_000985.csv\n<Response [200]>\nstk_sz_002372.csv\n<Response [200]>\nidx_sz_399806.csv\n<Response [200]>\nstk_sz_002304.csv\n<Response [200]>\nidx_sz_399330.csv\n<Response [200]>\nstk_sh_601009.csv\n<Response [200]>\nstk_sh_600612.csv\n<Response [200]>\nstk_sz_000002.csv\n<Response [200]>\nmcr_ucy.csv\n<Response [200]>\nidx-img-pes.png\n<Response [400]>\nidx-img-pes.png\nidx_hw_gdaxi.csv\n<Response [200]>\nidu_sw1_801040.csv\n<Response [200]>\nplt_change.csv\n<Response [200]>\nidx_sz_399814.csv\n<Response [200]>\nidu_sw1_801160.csv\n<Response [200]>\nidx_value.csv\n<Response [200]>\nidu_sw1_801720.csv\n<Response [200]>\n"
    }
   ],
   "source": [
    "#引入包\n",
    "import pandas as pd\n",
    "import requests,json,time,os\n",
    "\n",
    "\n",
    "# headers\n",
    "header={\n",
    "    \"HOST\":'www.joinquant.com',\n",
    "    'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Safari/537.36 Core/1.70.3741.400 QQBrowser/10.5.3863.400',\n",
    "    \"Referer\": \"https://www.joinquant.com/user/22486821351/edit/Data/idx_sz_399975-Copy1.csv\"\n",
    "    }\n",
    "\n",
    "# cookies\n",
    "def get_cookies():\n",
    "    cookies_str='user-22486821351=2|1:0|10:1580441327|16:user-22486821351|48:Yzk1NDUyMDMtODA1NC00MzhlLTk0ZDEtMTAzMmQxNDBjM2Y2|c239f118b6ff961da39a5c94c9f9d6d3797d7e2e307e3ed767133cc5fd9d5205; uid=CiyeXF4nFB6RJwVGnDP3Ag==; gr_user_id=4888dc93-fdda-4579-9b6b-143b29e085cf; UM_distinctid=16fc8a6addf102-00f87b01990676-34564a7c-144000-16fc8a6ade242c; _xsrf=2|5696dfdb|22d9f82efd1303fd8b35829e891bdc2e|1579619405; hideBanner=1; token=2de71b6063fdf241fd25b2afc0ffca4bb2fdedc0; Hm_lvt_aab1c038280787bd3547c63800577e6b=1580390254,1580391292,1580399696,1580441364; PHPSESSID=vv3k6p9gcfkpgnmilh0ug5smf2; gr_cs1_6a7c9d65-f791-4b11-88c3-150d8e0f047b=user_id%3A70c77a62964c3cfcac500ba608f87373; CNZZDATA1256107754=189823841-1579616418-https%253A%252F%252Fwww.baidu.com%252F%7C1580445163; gr_session_id_949f6a566feb9b09=cbda1960-8812-4436-a793-42f421deab59; Hm_lpvt_aab1c038280787bd3547c63800577e6b=1580445902; gr_session_id_949f6a566feb9b09_cbda1960-8812-4436-a793-42f421deab59=true; gr_cs1_cbda1960-8812-4436-a793-42f421deab59=user_id%3A70c77a62964c3cfcac500ba608f87373'\n",
    "    #cookies_str转换为字典格式\n",
    "    cookies_str=cookies_str.split('; ')\n",
    "    cookies={}\n",
    "    for item in cookies_str:\n",
    "        temp=item.split('=')\n",
    "        cookies[temp[0]]=temp[1]  \n",
    "    return cookies\n",
    "\n",
    "\n",
    "file_list=['stk_sz_002415.csv',\n",
    "'mcr_u10y.csv',\n",
    "'cmm_value.csv',\n",
    " 'idx_sh_000977.csv',\n",
    " 'idx_sz_399976.csv',\n",
    " 'mcr_u5y.csv',\n",
    " 'stk_bank_change.csv',\n",
    " 'cmm_gsr.csv',\n",
    " 'idu_sw1_801130.csv',\n",
    " 'stk_sz_002807.csv',\n",
    " 'stk_pool_gw300.csv',\n",
    " 'stk_pool_gwcyb.csv',\n",
    " 'stk_sh_600036.csv',\n",
    " 'idx_sh_000931.csv',\n",
    " 'idu_sw1_change.csv',\n",
    " 'idx_relevance.csv',\n",
    " 'idu_sw1_801110.csv',\n",
    " 'idx-img-qscpe.png',\n",
    " 'idu_sw1_801180.csv',\n",
    " 'mcr_bdi.csv',\n",
    " 'msg_xqwz_4776750571.csv',\n",
    " 'stk_sh_600887.csv',\n",
    " 'msg_blog_60278066.csv',\n",
    " 'stk_sh_600566.csv',\n",
    " 'idu_sw1_801080.csv',\n",
    " 'stk_sh_601166.csv',\n",
    " 'idx-img-kj.png',\n",
    " 'stk_sh_601818.csv',\n",
    " 'msg_xqwz_5941996397.csv',\n",
    " 'stk_pool_gw1000.csv',\n",
    " 'idx_sh_000989.csv',\n",
    " 'idx_data.db',\n",
    " 'mcr_udi.csv',\n",
    " 'idu_sw1_801150.csv',\n",
    " 'idu_sw1_801760.csv',\n",
    " 'idx_sh_000015.csv',\n",
    " 'idx_sh_000990.csv',\n",
    " 'idx_hw_spx.csv',\n",
    " 'idx_sz_399106.csv',\n",
    " 'idx_hw_n225.csv',\n",
    " 'idx_sz_399550.csv',\n",
    " 'stk_sh_600015.csv',\n",
    " 'msg_weixin_长赢指数投资.csv',\n",
    " 'idu_sw1_801710.csv',\n",
    " 'mcr_vix.csv',\n",
    " 'idu_sw1_801880.csv',\n",
    " 'stk_roe20_value.csv',\n",
    " 'mcr_scn.csv',\n",
    " 'idx_sz_399812.csv',\n",
    " 'msg_weibo_1254381361.csv',\n",
    " 'plt_sha.csv',\n",
    " 'idx_relevance.png',\n",
    " 'stk_sh_600660.csv',\n",
    " 'mcr_c5y.csv',\n",
    " 'idx_sh_000991.csv',\n",
    " 'msg_weixin_梧桐拾贝社.csv',\n",
    " 'idx_hw_hsi.csv',\n",
    " 'idu_sw1_801210.csv',\n",
    " 'stk_sh_601877.csv',\n",
    " 'idx_change.csv',\n",
    " 'idx_hw_ftse.csv',\n",
    " 'stk_sh_600016.csv',\n",
    " 'idx_sz_399989.csv',\n",
    " 'idx_pool.csv',\n",
    " 'stk_sh_601229.csv',\n",
    " 'stk_sz_002294.csv',\n",
    " 'stk_pool_roe20.csv',\n",
    " 'stk_sh_600926.csv',\n",
    " 'idx_sh_000922.csv',\n",
    " 'idx_sh_000068.csv',\n",
    " 'idx_sz_399975.csv',\n",
    " 'stk_pool_gw500.csv',\n",
    " 'stk_sh_600919.csv',\n",
    " 'idx_sz_399811.csv',\n",
    " 'idu_sw1_801770.csv',\n",
    " 'idx_sz_399986.csv',\n",
    " 'idx_hw_fchi.csv',\n",
    " 'stk_sz_002236.csv',\n",
    " 'stk_sz_002714.csv',\n",
    " 'idx-img-pbs.png',\n",
    " 'stk_sh_601939.csv',\n",
    " 'mcr_pmi.csv',\n",
    " 'mcr_uch.csv',\n",
    " 'stk_sz_000661.csv',\n",
    " 'idu_sw1_801890.csv',\n",
    " 'idu_sw1_801120.csv',\n",
    " 'stk_bank_value.csv',\n",
    " 'idx_sh_000010.csv',\n",
    " 'idu_sw1_801050.csv',\n",
    " 'mcr_cpi.csv',\n",
    " 'idx_sh_000827.csv',\n",
    " 'idx_sh_000906.csv',\n",
    " 'msg_weixin_码农滚雪球.csv',\n",
    " 'stk_sh_600816.csv',\n",
    " 'idu_sw1_801200.csv',\n",
    " 'idx_sh_000841.csv',\n",
    " 'idx-img-qscpb.png',\n",
    " 'idu_sw1_801740.csv',\n",
    " 'stk_pool_bank.csv',\n",
    " 'stk_roe20_change.csv',\n",
    " 'idx_sz_399001.csv',\n",
    " 'stk_sz_000688.csv',\n",
    " 'cmm_oil.csv',\n",
    " 'stk_sh_601988.csv',\n",
    " 'idu_sw1_801030.csv',\n",
    " 'idx_hw_hscei.csv',\n",
    " 'idx_sh_000016.csv',\n",
    " 'stk_sz_000333.csv',\n",
    " 'stk_sz_000001.csv',\n",
    " 'stk_sz_000538.csv',\n",
    " 'msg_weibo_1669616825.csv',\n",
    " 'plt_value.csv',\n",
    " 'fnd_pool_index.csv',\n",
    " 'cmm_xau.csv',\n",
    " 'idx_sz_399101.csv',\n",
    " 'idx_sz_399324.csv',\n",
    " 'idx_hw_sx5e.csv',\n",
    " 'idu_sw1_801750.csv',\n",
    " 'idu_sw1_801780.csv',\n",
    " 'mcr_ms.csv',\n",
    " 'idx_sh_000902.csv',\n",
    " 'stk_sz_002142.csv',\n",
    " 'stk_sh_600908.csv',\n",
    " 'stk_sh_601398.csv',\n",
    " 'idx_sh_000993.csv',\n",
    " 'stk_sz_002081.csv',\n",
    " 'idu_sw1_value.csv',\n",
    " 'cmm_gor.csv',\n",
    " 'stk_sz_000651.csv',\n",
    " 'mcr_pool.csv',\n",
    " 'stk_sh_600000.csv',\n",
    " 'idx_sh_000300.csv',\n",
    " 'idu_sw1_801140.csv',\n",
    " 'stk_sh_601997.csv',\n",
    " 'idx_sz_399967.csv',\n",
    " 'stk_sh_601288.csv',\n",
    " 'idx_hw_ndaq.csv',\n",
    " 'idx-img-zj.png',\n",
    " 'stk_sh_601998.csv',\n",
    " 'msg_weixin_股市药丸.csv',\n",
    " 'stk_sh_603288.csv',\n",
    " 'stk_sh_600690.csv',\n",
    " 'idx_sz_399005.csv',\n",
    " 'plt_cyb.csv',\n",
    " 'mcr_shibor.csv',\n",
    " 'cmm_pool.csv',\n",
    " 'idu_sw1_801020.csv',\n",
    " 'idx_sh_000009.csv',\n",
    " 'stk_sh_601169.csv',\n",
    " 'stk_sh_603323.csv',\n",
    " 'stk_sh_600201.csv',\n",
    " 'idx_sh_000001.csv',\n",
    " 'mcr_c10y.csv',\n",
    " 'plt_sza.csv',\n",
    " 'idx_sh_000998.csv',\n",
    " '.ipynb_checkpoints',\n",
    " 'idu_sw1_801170.csv',\n",
    " 'stk_pool_edticket.csv',\n",
    " 'idx_sh_000807.csv',\n",
    " 'stk_sh_603898.csv',\n",
    " 'idx_sh_000992.csv',\n",
    " 'stk_sz_000423.csv',\n",
    " 'plt_zxb.csv',\n",
    " 'idx_sz_399997.csv',\n",
    " 'idx_sz_399624.csv',\n",
    " 'cmm_xag.csv',\n",
    " 'idx_sz_399006.csv',\n",
    " 'idx_sh_000905.csv',\n",
    " 'stk_sh_601515.csv',\n",
    " 'mcr_ppi.csv',\n",
    " 'stk_sz_000963.csv',\n",
    " 'plt_hsa.csv',\n",
    " 'idx_sh_000932.csv',\n",
    " 'msg_weixin_阿甘数量化2.csv',\n",
    " 'idx_sz_399808.csv',\n",
    " 'idx_sz_399673.csv',\n",
    " 'idx_sh_000925.csv',\n",
    " 'stk_sh_601128.csv',\n",
    " 'stk_sz_002271.csv',\n",
    " 'idu_sw1_801790.csv',\n",
    " 'msg_weibo_5687069307.csv',\n",
    " 'idx_sh_000904.csv',\n",
    " 'plt_szb.csv',\n",
    " 'plt_pool.csv',\n",
    " 'mcr_nfc.csv',\n",
    " 'msg_xqft_4776750571.csv',\n",
    " 'stk_sz_002508.csv',\n",
    " 'idu_sw1_801010.csv',\n",
    " 'stk_sz_002032.csv',\n",
    " 'idx_sh_000903.csv',\n",
    " 'idu_pool_sw1.csv',\n",
    " 'stk_sh_600276.csv',\n",
    " 'idu_sw1_801730.csv',\n",
    " 'idx_sh_000852.csv',\n",
    " 'idx_sh_000986.csv',\n",
    " 'stk_sh_600340.csv',\n",
    " 'cmm_change.csv',\n",
    " 'idx_sh_000988.csv',\n",
    " 'idx_sh_000978.csv',\n",
    " 'idx_sz_399396.csv',\n",
    " 'stk_sh_600519.csv',\n",
    " 'stk_sz_000049.csv',\n",
    " 'idx_hw_djia.csv',\n",
    " 'idx_sz_399971.csv',\n",
    " 'idx_sz_399102.csv',\n",
    " 'idu_sw1_801230.csv',\n",
    " '网格-交易A.xlsm',\n",
    " 'mcr_gdp.csv',\n",
    " 'idx_sh_000985.csv',\n",
    " 'stk_sz_002372.csv',\n",
    " 'idx_sz_399806.csv',\n",
    " 'stk_sz_002304.csv',\n",
    " 'idx_sz_399330.csv',\n",
    " 'stk_sh_601009.csv',\n",
    " 'stk_sh_600612.csv',\n",
    " 'stk_sz_000002.csv',\n",
    " 'mcr_ucy.csv',\n",
    " 'idx-img-pes.png',\n",
    " 'idx_hw_gdaxi.csv',\n",
    " 'idu_sw1_801040.csv',\n",
    " 'plt_change.csv',\n",
    " 'idx_sz_399814.csv',\n",
    " 'idu_sw1_801160.csv',\n",
    " 'idx_value.csv',\n",
    " 'idu_sw1_801720.csv']\n",
    "\n",
    "cookies=get_cookies()\n",
    "\n",
    "for fn in file_list:\n",
    "\n",
    "    url=\"https://www.joinquant.com/user/22486821351/api/contents/Data/%s?type=file&format=text&_=1580445911713\"%(fn)\n",
    "\n",
    "    try:\n",
    "        r=requests.get(url,cookies=cookies,headers=header)\n",
    "        print(fn)\n",
    "        print(r)\n",
    "        data=json.loads(r.text).get('content')\n",
    "        if fn.endwith(\"csv\")\n",
    "        mode=iif()\n",
    "        with open('../Data/%s'%(fn), 'w', encoding='utf-8') as f:\n",
    "            f.write(data)\n",
    "    except:\n",
    "        print(fn)        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [],
   "source": [
    "import sys\n",
    "\n",
    "sys.path.append(\"../DS\")\n",
    "\n",
    "from ds import *\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'Sina' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-23-8fe696a92fdd>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdsData\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mhist\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"OIL\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;32mf:\\code\\Python\\Quant\\Quant\\DS\\ds.py\u001b[0m in \u001b[0;36mhist\u001b[1;34m(code, start_date, end_date, fields, period)\u001b[0m\n\u001b[0;32m    569\u001b[0m         ]:\n\u001b[0;32m    570\u001b[0m             \u001b[1;32mif\u001b[0m \u001b[0mdata\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0min_codes\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mcode\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 571\u001b[1;33m                 \u001b[1;32mreturn\u001b[0m \u001b[0mdata\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mhist\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mcode\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mstart_date\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mend_date\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mfields\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    572\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    573\u001b[0m     \u001b[1;33m@\u001b[0m\u001b[0mstaticmethod\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mf:\\code\\Python\\Quant\\Quant\\DS\\ds.py\u001b[0m in \u001b[0;36mhist\u001b[1;34m(code, start_date, end_date, fields, period)\u001b[0m\n\u001b[0;32m    443\u001b[0m     \u001b[1;32mdef\u001b[0m \u001b[0mhist\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mcode\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mstart_date\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mNone\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mend_date\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mNone\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mfields\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mNone\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mperiod\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m'D'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    444\u001b[0m         \u001b[1;31m# 新浪网财经数据\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 445\u001b[1;33m         \u001b[1;32mreturn\u001b[0m \u001b[0mSina\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mhist_price\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mcode\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mstart_date\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mend_date\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    446\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    447\u001b[0m     \u001b[1;33m@\u001b[0m\u001b[0mclassmethod\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mNameError\u001b[0m: name 'Sina' is not defined"
     ]
    }
   ],
   "source": [
    "print(dsData.hist(\"OIL\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'Xueqiu' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-14-2ae02f8198cd>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mdsData\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mhist\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"HSI\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;32mf:\\code\\Python\\Quant\\Quant\\DS\\ds.py\u001b[0m in \u001b[0;36mhist\u001b[1;34m(code, start_date, end_date, fields, period)\u001b[0m\n\u001b[0;32m    569\u001b[0m         ]:\n\u001b[0;32m    570\u001b[0m             \u001b[1;32mif\u001b[0m \u001b[0mdata\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0min_codes\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mcode\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 571\u001b[1;33m                 \u001b[1;32mreturn\u001b[0m \u001b[0mdata\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mhist\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mcode\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mstart_date\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mend_date\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mfields\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    572\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    573\u001b[0m     \u001b[1;33m@\u001b[0m\u001b[0mstaticmethod\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mf:\\code\\Python\\Quant\\Quant\\DS\\ds.py\u001b[0m in \u001b[0;36mhist\u001b[1;34m(code, start_date, end_date, fields, period)\u001b[0m\n\u001b[0;32m    226\u001b[0m     \u001b[1;32mdef\u001b[0m \u001b[0mhist\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mcode\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mstart_date\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mNone\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mend_date\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mNone\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mfields\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mNone\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mperiod\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m'D'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    227\u001b[0m         \u001b[1;31m# 雪球官网数据\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 228\u001b[1;33m         \u001b[0mdf\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mXueqiu\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mhist_price\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mcode\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mstart_date\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    229\u001b[0m         \u001b[1;32mif\u001b[0m \u001b[0mdf\u001b[0m \u001b[1;32mis\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    230\u001b[0m             \u001b[1;32mreturn\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mNameError\u001b[0m: name 'Xueqiu' is not defined"
     ]
    }
   ],
   "source": [
    "dsData.hist(\"HSI\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from tkinter import *\n",
    "from tkinter import ttk\n",
    "import random\n",
    "\n",
    "root = Tk()\n",
    "root.title('MyApp')\n",
    "root.resizable(width=False, height=False)\n",
    "root.config(background='#EEE')\n",
    "root.geometry('300x150')\n",
    "\n",
    "def gen():\n",
    "    val.set(repr(random.random()))\n",
    "\n",
    "val = StringVar()\n",
    "val.set('3.14')\n",
    "ttk.Frame(root, height=20).grid()\n",
    "lb=ttk.Entry(root,textvariable=val).grid(row=1, column=1, pady=10, padx=10,ipady=5,sticky='nsew')\n",
    "bt = ttk.Button(root, text='Random', width=20, command=gen).grid(\n",
    "    row=2, column=1, ipady=10, ipadx=10, sticky=E)\n",
    "\n",
    "root.mainloop()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3.7.4 64-bit ('ProgramData': virtualenv)",
   "language": "python",
   "name": "python37464bitprogramdatavirtualenv15933603a28f4019abb268061593605c"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "3.7.4-final"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}